;d:\AutoHotKey\AutoHotkey.exe "D:\workspace 空格\AtiBrow\actPlayWin.kmplayer.ahk"
DetectHiddenWindows,On
 ;SetTitleMatchMode,1
 
 
play_stat=0
close_evt()
{

		WinGet, active_id2, ID, ahk_class SunAwtFrame
		;MsgBox %active_id2%
		WinActivate,  ahk_class SunAwtFrame
		;msgbox,"close evt .."
		MouseMove,10,100
		MouseClick,Middle
		Sleep, 1000
		
		MouseMove,10,100
		MouseClick,Middle
	

}

closeKmP_info()
{
     info_win=ahk_class TCodecAlertForm
     IfWinExist,%info_win%
	{
	    WinClose,%info_win%
	}

}

closePotUpInfo()
{
	   info_win=ahk_class #32770
     IfWinExist,%info_win%
	{
	    WinClose,%info_win%
	}
	

}

actMainWin()
{
	WinGet, active_id2, ID, ahk_class SunAwtFrame
		;MsgBox %active_id2%
		WinActivate,  ahk_class SunAwtFrame
		;act web frmk,only mouse mid key click
		MouseMove,10,100
		;	MouseClick,Middle
		;cancel loop act mainwin   for  tab search box input txt

		ControlFocus,Internet Explorer_Server
		ControlFocus,Internet Explorer_Server1



}

closeFFmpegWin()
{

   WinClose,ffmpeg.exe
}

Loop
{
 
	;-----------actplayer win
	player=ahk_class KMPlayer v3.x
	player2=ahk_class PotPlayer64
	player3=ahk_class XLUEFrameHostWnd
    IfWinExist,%player%
	{
		;close_event
		WinGet, active_id, ID,ahk_class KMPlayer v3.x
	 ;	MsgBox %active_id%
		WinActivate,ahk_class KMPlayer v3.x
		WinMaximize,ahk_class KMPlayer v3.x

		;; ,,Everything,Everything
		PostMessage,0x112, 0xF030,,, ahk_class KMPlayer v3.x
		play_stat=1
	}
	else  IfWinExist,%player2%
	{
		WinGet, active_id, ID,%player2%
		WinActivate,%player2%
		WinMaximize,%player2%
		play_stat=1
	}
	else  IfWinExist,%player3%
	{
		WinGet, active_id, ID,%player3%
		WinActivate,%player3%
		WinMaximize,%player3%
		play_stat=1
	}
	
	else
	{
		;msgbox,playwinNotExist %play_stat%
		if( play_stat=1)
		{
				;	msgbox,"close evt ..22"
				close_evt()
				play_stat=0
		 }
	}
	

	;MsgBox  aa
	;-------------------act  mainwin
	 IfWinNotExist,ahk_class KMPlayer v3.x
	 {	
		IfWinNotExist,%player2%
		{
			IfWinNotExist,%player3%
			{
			actMainWin()
			}
		}
		
	}
	
	
	closeKmP_info()
	closePotUpInfo()
	  WinClose,ffmpeg.exe
	
;msgbox tt
Sleep, 5000
}

#c:: ExitApp